package com.essearch.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.essearch.common.TableFieldEnum;
import com.essearch.entity.*;
import com.essearch.repository.Item_mainRepository;
import com.essearch.repository.Item_person_baseRepository;
import com.essearch.repository.Jhrw_itemRepository;
import com.essearch.repository.Jhrw_unitRepository;
import com.essearch.service.EsSearchService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.DeleteQuery;
import org.springframework.data.elasticsearch.core.query.GetQuery;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * elasticsearch 搜索引擎 service实现
 */
@Service
public class EsSearchServiceImpl extends BaseSearchServiceImpl implements EsSearchService {
    private Logger log = LoggerFactory.getLogger(getClass());
    @Value("database.name")
    private String dbName;

    @Resource
    private ElasticsearchTemplate elasticsearchTemplate;
//    @Resource
//    private Item_01Repository item01Repository;
//    @Resource
//    private Item_01_extRepository item_01_extRepository;
//    @Resource
//    private Item_01_listRepository item_01_listRepository;
//    @Resource
//    private Item_01_list2Repository item_01_list2Repository;
//    @Resource
//    private Item_01_personRepository item_01_personRepository;
//    @Resource
//    private Item_02Repository item_02Repository;
//    @Resource
//    private Item_02_extRepository item_02_extRepository;
//    @Resource
//    private Item_03Repository item_03Repository;
//    @Resource
//    private Item_03_20181222Repository item_03_20181222Repository;
//    @Resource
//    private Item_03_extRepository item_03_extRepository;
//    @Resource
//    private Item_03_ext_20181222Repository item_03_ext_20181222Repository;
//    @Resource
//    private Item_04Repository item_04Repository;
//    @Resource
//    private Item_04_extRepository item_04_extRepository;
//    @Resource
//    private Item_05Repository item_05Repository;
//    @Resource
//    private Item_05_20181222Repository item_05_20181222Repository;
//    @Resource
//    private Item_05_extRepository item_05_extRepository;
//    @Resource
//    private Item_06Repository item_06Repository;
//    @Resource
//    private Item_06_extRepository item_06_extRepository;
//    @Resource
//    private Item_06_jfbzRepository item_06_jfbzRepository;
//    @Resource
//    private Item_06_sbyqRepository item_06_sbyqRepository;
//    @Resource
//    private Item_06_yjkfhdRepository item_06_yjkfhdRepository;
//    @Resource
//    private Item_06_zongheRepository item_06_zongheRepository;
//    @Resource
//    private Item_06_zycpRepository item_06_zycpRepository;
//    @Resource
//    private Item_06_zyktRepository item_06_zyktRepository;
//    @Resource
//    private Item_07Repository item_07Repository;
//    @Resource
//    private Item_07_extRepository item_07_extRepository;
//    @Resource
//    private Item_08Repository item_08Repository;
//    @Resource
//    private Item_08_extRepository item_08_extRepository;
//    @Resource
//    private Item_09Repository item_09Repository;
//    @Resource
//    private Item_09_cwzkRepository item_09_cwzkRepository;
//    @Resource
//    private Item_09_feeRepository item_09_feeRepository;
//    @Resource
//    private Item_09_ryjgRepository item_09_ryjgRepository;
//    @Resource
//    private Item_09_yjfxRepository item_09_yjfxRepository;
//    @Resource
//    private Item_10Repository item_10Repository;
//    @Resource
//    private Item_10_extRepository item_10_extRepository;
//    @Resource
//    private Item_10_kjjlxmRepository item_10_kjjlxmRepository;
//    @Resource
//    private Item_10_lwRepository item_10_lwRepository;
//    @Resource
//    private Item_10_ptjdRepository item_10_ptjdRepository;
//    @Resource
//    private Item_10_sqxzlRepository item_10_sqxzlRepository;
//    @Resource
//    private Item_10_zykjxmRepository item_10_zykjxmRepository;
//    @Resource
//    private Item_11Repository item_11Repository;
//    @Resource
//    private Item_11_extRepository item_11_extRepository;
//    @Resource
//    private Item_11_hzjbqkRepository item_11_hzjbqkRepository;
//    @Resource
//    private Item_12Repository item_12Repository;
//    @Resource
//    private Item_12_extRepository item_12_extRepository;
//    @Resource
//    private Item_13Repository item_13Repository;
//    @Resource
//    private Item_14Repository item_14Repository;
//    @Resource
//    private Item_14_extRepository item_14_extRepository;
//    @Resource
//    private Item_15Repository item_15Repository;
//    @Resource
//    private Item_15_extRepository item_15_extRepository;
//    @Resource
//    private Item_16Repository item_16Repository;
    @Resource
    private Item_mainRepository item_mainRepository;
//    @Resource
//    private Item_personRepository item_personRepository;
    @Resource
    private Item_person_baseRepository item_person_baseRepository;
//    @Resource
//    private Item_person_eduRepository item_person_eduRepository;
//    @Resource
//    private Item_person_extRepository item_person_extRepository;
//    @Resource
//    private Item_person_workRepository item_person_workRepository;
//    @Resource
//    private Item_unitRepository item_unitRepository;
//    @Resource
//    private Item_unit_extRepository item_unit_extRepository;
    @Resource
    private Jhrw_itemRepository jhrw_itemRepository;
    @Resource
    private Jhrw_unitRepository jhrw_unitRepository;
//    @Resource
//    private Request_personRepository request_personRepository;
//    @Resource
//    private Request_person_extRepository request_person_extRepository;
//    @Resource
//    private Request_unitRepository request_unitRepository;
//    @Resource
//    private Request_unit_extRepository request_unit_extRepository;

    @Override
    public void saveAll(List<Object> list) {
        if (CollectionUtils.isNotEmpty(list)){
            Object result = null;
            if (list.get(0) instanceof Item_01){
                elasticsearchTemplate.putMapping(Item_01.class);

                ArrayList<Item_01> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_01) o));
//                result = item01Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_01_ext){
                elasticsearchTemplate.putMapping(Item_01_ext.class);

                ArrayList<Item_01_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_01_ext) o));
//                result = item_01_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_01_list){
                elasticsearchTemplate.putMapping(Item_01_list.class);

                ArrayList<Item_01_list> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_01_list) o));
//                result = item_01_listRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_01_list2){
                elasticsearchTemplate.putMapping(Item_01_list2.class);

                ArrayList<Item_01_list2> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_01_list2) o));
//                result = item_01_list2Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_01_person){
                elasticsearchTemplate.putMapping(Item_01_person.class);

                ArrayList<Item_01_person> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_01_person) o));
//                result = item_01_personRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_02){
                elasticsearchTemplate.putMapping(Item_02.class);

                ArrayList<Item_02> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_02) o));
//                result = item_02Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_02_ext){
                elasticsearchTemplate.putMapping(Item_02_ext.class);

                ArrayList<Item_02_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_02_ext) o));
//                result = item_02_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_03){
                elasticsearchTemplate.putMapping(Item_03.class);

                ArrayList<Item_03> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_03) o));
//                result = item_03Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_03_20181222){
                elasticsearchTemplate.putMapping(Item_03_20181222.class);

                ArrayList<Item_03_20181222> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_03_20181222) o));
//                result = item_03_20181222Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_03_ext){
                elasticsearchTemplate.putMapping(Item_03_ext.class);

                ArrayList<Item_03_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_03_ext) o));
//                result = item_03_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_03_ext_20181222){
                elasticsearchTemplate.putMapping(Item_03_ext_20181222.class);

                ArrayList<Item_03_ext_20181222> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_03_ext_20181222) o));
//                result = item_03_ext_20181222Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_04){
                elasticsearchTemplate.putMapping(Item_04.class);

                ArrayList<Item_04> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_04) o));
//                result = item_04Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_04_ext){
                elasticsearchTemplate.putMapping(Item_04_ext.class);

                ArrayList<Item_04_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_04_ext) o));
//                result = item_04_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_05){
                elasticsearchTemplate.putMapping(Item_05.class);

                ArrayList<Item_05> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_05) o));
//                result = item_05Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_05_20181222){
                elasticsearchTemplate.putMapping(Item_05_20181222.class);

                ArrayList<Item_05_20181222> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_05_20181222) o));
//                result = item_05_20181222Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_05_ext){
                elasticsearchTemplate.putMapping(Item_05_ext.class);

                ArrayList<Item_05_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_05_ext) o));
//                result = item_05_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_06){
                elasticsearchTemplate.putMapping(Item_06.class);

                ArrayList<Item_06> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_06) o));
//                result = item_06Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_06_ext){
                elasticsearchTemplate.putMapping(Item_06_ext.class);

                ArrayList<Item_06_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_06_ext) o));
//                result = item_06_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_06_jfbz){
                elasticsearchTemplate.putMapping(Item_06_jfbz.class);

                ArrayList<Item_06_jfbz> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_06_jfbz) o));
//                result = item_06_jfbzRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_06_sbyq){
                elasticsearchTemplate.putMapping(Item_06_sbyq.class);

                ArrayList<Item_06_sbyq> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_06_sbyq) o));
//                result = item_06_sbyqRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_06_yjkfhd){
                elasticsearchTemplate.putMapping(Item_06_yjkfhd.class);

                ArrayList<Item_06_yjkfhd> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_06_yjkfhd) o));
//                result = item_06_yjkfhdRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_06_zonghe){
                elasticsearchTemplate.putMapping(Item_06_zonghe.class);

                ArrayList<Item_06_zonghe> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_06_zonghe) o));
//                result = item_06_zongheRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_06_zycp){
                elasticsearchTemplate.putMapping(Item_06_zycp.class);

                ArrayList<Item_06_zycp> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_06_zycp) o));
//                result = item_06_zycpRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_06_zykt){
                elasticsearchTemplate.putMapping(Item_06_zykt.class);

                ArrayList<Item_06_zykt> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_06_zykt) o));
//                result = item_06_zyktRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_07){
                elasticsearchTemplate.putMapping(Item_07.class);

                ArrayList<Item_07> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_07) o));
//                result = item_07Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_07_ext){
                elasticsearchTemplate.putMapping(Item_07_ext.class);

                ArrayList<Item_07_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_07_ext) o));
//                result = item_07_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_08){
                elasticsearchTemplate.putMapping(Item_08.class);

                ArrayList<Item_08> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_08) o));
//                result = item_08Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_08_ext){
                elasticsearchTemplate.putMapping(Item_08_ext.class);

                ArrayList<Item_08_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_08_ext) o));
//                result = item_08_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_09){
                elasticsearchTemplate.putMapping(Item_09.class);

                ArrayList<Item_09> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_09) o));
//                result = item_09Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_09_cwzk){
                elasticsearchTemplate.putMapping(Item_09_cwzk.class);

                ArrayList<Item_09_cwzk> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_09_cwzk) o));
//                result = item_09_cwzkRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_09_fee){
                elasticsearchTemplate.putMapping(Item_09_fee.class);

                ArrayList<Item_09_fee> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_09_fee) o));
//                result = item_09_feeRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_09_ryjg){
                elasticsearchTemplate.putMapping(Item_09_ryjg.class);

                ArrayList<Item_09_ryjg> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_09_ryjg) o));
//                result = item_09_ryjgRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_09_yjfx){
                elasticsearchTemplate.putMapping(Item_09_yjfx.class);

                ArrayList<Item_09_yjfx> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_09_yjfx) o));
//                result = item_09_yjfxRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_10){
                elasticsearchTemplate.putMapping(Item_10.class);

                ArrayList<Item_10> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_10) o));
//                result = item_10Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_10_ext){
                elasticsearchTemplate.putMapping(Item_10_ext.class);

                ArrayList<Item_10_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_10_ext) o));
//                result = item_10_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_10_kjjlxm){
                elasticsearchTemplate.putMapping(Item_10_kjjlxm.class);

                ArrayList<Item_10_kjjlxm> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_10_kjjlxm) o));
//                result = item_10_kjjlxmRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_10_lw){
                elasticsearchTemplate.putMapping(Item_10_lw.class);

                ArrayList<Item_10_lw> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_10_lw) o));
//                result = item_10_lwRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_10_ptjd){
                elasticsearchTemplate.putMapping(Item_10_ptjd.class);

                ArrayList<Item_10_ptjd> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_10_ptjd) o));
//                result = item_10_ptjdRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_10_sqxzl){
                elasticsearchTemplate.putMapping(Item_10_sqxzl.class);

                ArrayList<Item_10_sqxzl> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_10_sqxzl) o));
//                result = item_10_sqxzlRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_10_zykjxm){
                elasticsearchTemplate.putMapping(Item_10_zykjxm.class);

                ArrayList<Item_10_zykjxm> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_10_zykjxm) o));
//                result = item_10_zykjxmRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_11){
                elasticsearchTemplate.putMapping(Item_11.class);

                ArrayList<Item_11> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_11) o));
//                result = item_11Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_11_ext){
                elasticsearchTemplate.putMapping(Item_11_ext.class);

                ArrayList<Item_11_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_11_ext) o));
//                result = item_11_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_11_hzjbqk){
                elasticsearchTemplate.putMapping(Item_11_hzjbqk.class);

                ArrayList<Item_11_hzjbqk> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_11_hzjbqk) o));
//                result = item_11_hzjbqkRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_12){
                elasticsearchTemplate.putMapping(Item_12.class);

                ArrayList<Item_12> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_12) o));
//                result = item_12Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_12_ext){
                elasticsearchTemplate.putMapping(Item_12_ext.class);

                ArrayList<Item_12_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_12_ext) o));
//                result = item_12_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_13){
                elasticsearchTemplate.putMapping(Item_13.class);

                ArrayList<Item_13> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_13) o));
//                result = item_13Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_14){
                elasticsearchTemplate.putMapping(Item_14.class);

                ArrayList<Item_14> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_14) o));
//                result = item_14Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_14_ext){
                elasticsearchTemplate.putMapping(Item_14_ext.class);

                ArrayList<Item_14_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_14_ext) o));
//                result = item_14_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_15){
                elasticsearchTemplate.putMapping(Item_15.class);

                ArrayList<Item_15> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_15) o));
//                result = item_15Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_15_ext){
                elasticsearchTemplate.putMapping(Item_15_ext.class);

                ArrayList<Item_15_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_15_ext) o));
//                result = item_15_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_16){
                elasticsearchTemplate.putMapping(Item_16.class);

                ArrayList<Item_16> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_16) o));
//                result = item_16Repository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_main){
                elasticsearchTemplate.putMapping(Item_main.class);

                ArrayList<Item_main> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_main) o));
                result = item_mainRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_person){
                elasticsearchTemplate.putMapping(Item_person.class);

                ArrayList<Item_person> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_person) o));
//                result = item_personRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_person_base){
                elasticsearchTemplate.putMapping(Item_person_base.class);

                ArrayList<Item_person_base> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_person_base) o));
                result = item_person_baseRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_person_edu){
                elasticsearchTemplate.putMapping(Item_person_edu.class);

                ArrayList<Item_person_edu> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_person_edu) o));
//                result = item_person_eduRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_person_ext){
                elasticsearchTemplate.putMapping(Item_person_ext.class);

                ArrayList<Item_person_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_person_ext) o));
//                result = item_person_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_person_work){
                elasticsearchTemplate.putMapping(Item_person_work.class);

                ArrayList<Item_person_work> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_person_work) o));
//                result = item_person_workRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_unit){
                elasticsearchTemplate.putMapping(Item_unit.class);

                ArrayList<Item_unit> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_unit) o));
//                result = item_unitRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Item_unit_ext){
                elasticsearchTemplate.putMapping(Item_unit_ext.class);

                ArrayList<Item_unit_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Item_unit_ext) o));
//                result = item_unit_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Request_person){
                elasticsearchTemplate.putMapping(Request_person.class);

                ArrayList<Request_person> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Request_person) o));
//                result = request_personRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Jhrw_item){
                elasticsearchTemplate.putMapping(Jhrw_item.class);

                ArrayList<Jhrw_item> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Jhrw_item) o));
                result = jhrw_itemRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Jhrw_unit){
                elasticsearchTemplate.putMapping(Jhrw_unit.class);

                ArrayList<Jhrw_unit> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Jhrw_unit) o));
                result = jhrw_unitRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Request_person_ext){
                elasticsearchTemplate.putMapping(Request_person_ext.class);

                ArrayList<Request_person_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Request_person_ext) o));
//                result = request_person_extRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Request_unit){
                elasticsearchTemplate.putMapping(Request_unit.class);

                ArrayList<Request_unit> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Request_unit) o));
//                result = request_unitRepository.saveAll(arrayList);
            } else if (list.get(0) instanceof Request_unit_ext){
                elasticsearchTemplate.putMapping(Request_unit_ext.class);

                ArrayList<Request_unit_ext> arrayList = new ArrayList<>();
                list.forEach(o -> arrayList.add((Request_unit_ext) o));
//                result = request_unit_extRepository.saveAll(arrayList);
            } else {
                log.error("没有匹配的实体");
                return;
            }

//            log.info("——保存——：{}",JSON.toJSONString(result));
            log.info("——保存成功——:{}", result);
        } else {
            log.error("要保存的索引不能为空");
        }
    }

    @Override
    public void delete(String id) {
    }

    @Override
    public void deleteAll() {
    }

    @Override
    public Object getById(String id) {
        GetQuery getQuery = new GetQuery();
        getQuery.setId(id);
//        return elasticsearchTemplate.queryForObject(getQuery, SysLog.class);
        return null;
    }

    @Override
    public List<Object> getAll() {
        List<Object> list = new ArrayList<>();
//        elasticsearchRepository.findAll().forEach(list::add);
        return list;
    }

    @Override
    public boolean saveDataToES(String object) {
        try {

            JSONObject jsonObject = JSONObject.parseObject(object);
            String tableName = jsonObject.getString("tableName");
            Class<?> aClass = TableFieldEnum.getClazz(tableName);

            ArrayList<Object> dataList = new ArrayList<>(JSON.parseArray(jsonObject.getString("data"), aClass));
            saveAll(dataList);

            log.info("-------------------------- Finally insert number total : " + dataList.size());
            return true;
        } catch (Exception e) {
            log.error("保存数据失败——" + e);
            return false;
        }
    }
}
